<template>
  <div class="grzx_container">
    <div class="main-div">
      <div class="header-div">
        <div class="logo-div">
          <img src="@/assets/images/logo.png" alt="无法加载图片" />
        </div>
      </div>
      <div class="body-div">
        <MyNav />
        <div class="location-div">
          <div class="parcel-div">
            <a href="./homePage.html">首页</a>
            <span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
            <a href="./grzx.html">个人中心</a>
            <span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
            <a href="./grzx.html">我的中心</a>
          </div>
        </div>
        <div class="wrapper-div">
          <div class="parcel-div">
            <div class="sideleft">
              <div class="parcel-div">
                <div class="head-portrait-div">
                  <img :src="uImg" alt="无法加载图片" />
                </div>
                <div class="userInfo-div">
                  <span>[{{ uUsername }}]</span>&nbsp;&nbsp;
                  <span @click="logout">[退出登录]</span>
                </div>
              </div>
              <div class="nav-div">
                <div class="mydeal-div">
                  <ul>
                    <li><a href="#">我的交易</a></li>
                    <li><a href="#">我的订单</a></li>
                    <li><a href="#">评价晒单</a></li>
                  </ul>
                </div>
                <div class="grzx-div">
                  <ul>
                    <li><a href="#">个人中心</a></li>
                    <li><router-link to="/grzx/center">我的中心</router-link></li>
                    <li><a href="./addrManage.html">地址管理</a></li>
                  </ul>
                </div>
                <div class="accountManage-div">
                  <ul>
                    <li><a href="#">账户管理</a></li>
                    <li><router-link to="/grzx/info">个人信息</router-link></li>
                    <li><router-link to="/grzx/password">修改密码</router-link></li>
                  </ul>
                </div>
              </div>
            </div>
            <router-view></router-view>
          </div>
        </div>
      </div>
      <MyFooter />
    </div>
  </div>
</template>

<script>
import MyFooter from '@/components/common/MyFooter.vue'
import MyNav from '@/components/common/MyNav.vue'
export default {
  name: 'grzx',
  data() {
    return {
      uUsername: '',
      uImg: ''
    }
  },
  created() {
    this.getUserInfo()
  },
  methods: {
    getUserInfo() {
      this.$http
        .get('/user/me')
        .then(res => {
          if (res.state === false) {
            return
          }
          this.uUsername = res.data.uUsername
          this.uImg = res.data.uImg
        })
        .catch(err => this.$message.error(err))
    },
    logout() {
      window.localStorage.clear()
      this.$router.push('/login')
    }
  },
  components: {
    MyFooter,
    MyNav
  }
}
</script>

<style lang="less" scoped>
.location-div {
  top: 0;
  z-index: 1;
  position: sticky;
  background-color: #fff;
  border-top: 1px solid #dbdbdb;
  border-bottom: 1px solid #dbdbdb;
  a {
    cursor: pointer;
    font-size: 14px;
    display: inline-block;
  }
  .parcel-div {
    width: 80%;
    margin: 0 auto;
    line-height: 40px;
  }
}

.wrapper-div {
  position: relative;
  padding: 20px 0 20px 0;
  background-color: #f5f5f5;
  border-bottom: 1px solid #dbdbdb;
  > .parcel-div {
    width: 80%;
    margin: 0 auto;
  }
  .parcel-div::after {
    content: '';
    clear: both;
    display: block;
  }
}

/********************* sideleft *********************/
.sideleft {
  width: 15%;
  float: left;
  font-size: 14px;
  text-align: center;
  padding: 10px 0 0 0;
  background-color: #fff;
  border: 1px solid #dbdbdb;
  .nav-div {
    ul {
      display: flex;
      margin: 0;
      flex-direction: column;
    }
  }
  .userInfo-div {
    position: relative;
    span {
      line-height: 40px;
    }
    span:last-child {
      cursor: pointer;
    }
  }
  .parcel-div {
    // border-bottom: 2px solid #a10000;
    border-bottom: 2px solid #009688;
    img {
      width: 92px;
      height: 92px;
    }
    li {
      display: block;
      font-size: 16px;
      position: relative;
    }
  }
  li:nth-child(1) {
    font-weight: bold;
  }
  li::after {
    top: 0;
    left: 0;
    width: 5%;
    content: '';
    height: 45px;
    position: absolute;
    transform: scaleY(0);
    transition: all 0.5s ease;
    background-color: #a10000;
  }
  li:hover::after {
    transform: scaleY(1);
    transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
  }
  .grzx-div li:nth-child(2) a {
    color: #a10000;
  }
}

/********************* sideright *********************/
.sideright {
  width: 73%;
  padding: 5%;
  float: right;
  background-color: #fff;
  border: 1px solid #dbdbdb;
  .top-div {
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #dbdbdb;
  }
  .grxx-div {
    padding-left: 10px;
    h4 {
      font-size: 16px;
      margin-bottom: 5px;
    }
    a {
      color: #a10000;
      font-size: 13px;
    }
  }
  .mailbox-div {
    flex-grow: 1;
    text-align: right;
  }
  .parcel-div {
    display: flex;
    flex: 1 1 50%;
    flex-wrap: wrap;
    padding: 5% 0 0 0;
    > div {
      width: 50%;
      display: flex;
      align-items: center;
      padding: 2% 0 2% 0;
    }
    span {
      font-size: 16px;
    }
    a {
      font-size: 12px;
    }
    strong {
      font-size: 16px;
      color: #a10000;
    }
  }
  .botton-div .imgdetail-div {
    padding: 0 0 0 10px;
  }
}

.body-div .nav-div li {
  padding: 0 10px;
  line-height: 45px;
  position: relative;
  display: inline-block;
}

a {
  color: rgba(0, 0, 0, 0.7);
}

ul {
  padding-left: 0;
}

.nav-div li a {
  display: block;
  padding: 0 10px;
  cursor: pointer;
  font-size: 16px;
}

.logo-div {
  float: left;
  margin-top: 2%;
  margin-bottom: 1%;
}

.header-div {
  width: 80%;
  margin: 0 auto;
}

.header-div::after {
  content: '';
  clear: both;
  display: block;
}
</style>
